package com.game.core.resp;

import lombok.*;
import lombok.experimental.Accessors;
import lombok.extern.slf4j.Slf4j;

import java.util.Date;

/**
 * 封装客户端请求的统一响应
 */
@Slf4j
@ToString
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@Builder(toBuilder = true)
@AllArgsConstructor
@NoArgsConstructor
public class ResponeData {
    /**
     * 响应信息说明
     */
    private int success;

    private String message;

    private int status;

    private Object data;

    public ResponeData success() {
        this.success = ResponseCode.SUCCESS.getSuccess();
        this.message = ResponseCode.SUCCESS.getMessage();
        this.status = ResponseCode.SUCCESS.getStatus();
        this.data = new Object();
        return this;
    }

    public ResponeData success(Object obj) {
        this.success = ResponseCode.SUCCESS.getSuccess();
        this.message = ResponseCode.SUCCESS.getMessage();
        this.status = ResponseCode.SUCCESS.getStatus();
        this.data = obj;
        return this;
    }

    public ResponeData success(ResponseCode responseCode, Object data) {
        this.success = responseCode.SUCCESS.getSuccess();
        this.message = responseCode.SUCCESS.getMessage();
        this.status = responseCode.SUCCESS.getStatus();
        this.data = data;
        return this;
    }

    public ResponeData fail(ResponseCode responseCode, Object data) {
        this.success = responseCode.SUCCESS.getSuccess();
        this.message = responseCode.SUCCESS.getMessage();
        this.status = responseCode.SUCCESS.getStatus();
        this.data = data;
        return this;
    }

    public ResponeData fail() {
        this.success = ResponseCode.FAIL.getSuccess();
        this.message = ResponseCode.FAIL.getMessage();
        this.status = ResponseCode.FAIL.getStatus();
        this.data = new Object();
        return this;
    }

    public ResponeData fail(String msg) {
        this.success = ResponseCode.FAIL.getSuccess();
        this.message = msg;
        this.status = ResponseCode.FAIL.getStatus();
        this.data = new Object();
        return this;
    }


    public ResponeData Register() {
        this.success = ResponseCode.TOKEN_Register.getSuccess();
        this.message = ResponseCode.TOKEN_Register.getMessage();
        this.status = ResponseCode.TOKEN_Register.getStatus();
        this.data = new Object();
        return this;
    }


    public ResponeData NoRegister() {
        this.success = ResponseCode.TOKEN_NoRegister.getSuccess();
        this.message = ResponseCode.TOKEN_NoRegister.getMessage();
        this.status = ResponseCode.TOKEN_NoRegister.getStatus();
        this.data = new Object();
        return this;
    }

    public ResponeData tokenInvalld() {
        this.success = ResponseCode.TOKEN_INVALID.getSuccess();
        this.message = ResponseCode.TOKEN_INVALID.getMessage();
        this.status = ResponseCode.TOKEN_INVALID.getStatus();
        this.data = new Object();
        return this;
    }

}
